<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<!--
NOTE: Requires Markdown Extra. See http://michelf.ca/projects/php-markdown/extra/
 -->
<p><link href="data:text/css;charset=utf-8,%0A%0Ahtml%2C%20body%2C%20div%2C%20span%2C%20applet%2C%20object%2C%20iframe%2C%20h1%2C%20h2%2C%20h3%2C%20h4%2C%20h5%2C%20h6%2C%20p%2C%20blockquote%2C%20pre%2C%20a%2C%20abbr%2C%20acronym%2C%20address%2C%20big%2C%20cite%2C%20code%2C%20del%2C%20dfn%2C%20em%2C%20img%2C%20ins%2C%20kbd%2C%20q%2C%20s%2C%20samp%2C%20small%2C%20strike%2C%20strong%2C%20sub%2C%20sup%2C%20tt%2C%20var%2C%20b%2C%20u%2C%20i%2C%20center%2C%20dl%2C%20dt%2C%20dd%2C%20ol%2C%20ul%2C%20li%2C%20fieldset%2C%20form%2C%20label%2C%20legend%2C%20table%2C%20caption%2C%20tbody%2C%20tfoot%2C%20thead%2C%20tr%2C%20th%2C%20td%2C%20article%2C%20aside%2C%20canvas%2C%20details%2C%20embed%2C%20figure%2C%20figcaption%2C%20footer%2C%20header%2C%20hgroup%2C%20menu%2C%20nav%2C%20output%2C%20ruby%2C%20section%2C%20summary%2C%20time%2C%20mark%2C%20audio%2C%20video%20%7B%0Amargin%3A%200%3B%0Apadding%3A%200%3B%0Aborder%3A%200%3B%0A%7D%0A%0Abody%20%7B%0Afont%2Dfamily%3A%20calibri%2C%20arial%2C%20freesans%2C%20clean%2C%20sans%2Dserif%3B%0Afont%2Dsize%3A%2011pt%3B%0Aline%2Dheight%3A%201%2E5%3B%0Acolor%3A%20%23000%3B%0Abackground%2Dcolor%3A%20%23fff%3B%0Apadding%3A%2070px%3B%0Amargin%3A%200%20auto%3B%0A%7D%0Abody%3E%2A%3Afirst%2Dchild%20%7B%0Amargin%2Dtop%3A%200%20%21important%3B%0A%7D%0Abody%3E%2A%3Alast%2Dchild%20%7B%0Amargin%2Dbottom%3A%200%20%21important%3B%0A%7D%0A%0Ap%2C%20blockquote%2C%20ul%2C%20ol%2C%20dl%2C%20pre%20%7B%0Amargin%3A%204px%200%3B%0A%7D%0A%0Ah1%2C%20h2%2C%20h3%2C%20h4%2C%20h5%2C%20h6%20%7B%0Afont%2Dfamily%3A%20Variable%20Bold%2C%20Calibri%2C%20Helvetica%2C%20arial%2C%20freesans%2C%20clean%2C%20sans%2Dserif%3B%0Amargin%3A%2020px%200%2010px%3B%0Acolor%3A%20rgb%28167%2C%2021%2C%200%29%3B%0Apadding%3A%200%3B%0Afont%2Dweight%3A%20bold%3B%0A%2Dwebkit%2Dfont%2Dsmoothing%3A%20antialiased%3B%0A%7D%0Ah1%20tt%2C%20h1%20code%2C%20h2%20tt%2C%20h2%20code%2C%20h3%20tt%2C%20h3%20code%2C%20h4%20tt%2C%20h4%20code%2C%20h5%20tt%2C%20h5%20code%2C%20h6%20tt%2C%20h6%20code%20%7B%0Afont%2Dsize%3A%20inherit%3B%0A%7D%0Ah1%20%7B%0Afont%2Dsize%3A%2028px%3B%0Apage%2Dbreak%2Dbefore%3A%20always%3B%0A%7D%0Ah2%20%7B%0Afont%2Dsize%3A%2024px%3B%0Aborder%2Dbottom%3A%201px%20solid%20%23ccc%3B%0A%7D%0Ah3%20%7B%0Afont%2Dsize%3A%2018px%3B%0A%7D%0Ah4%20%7B%0Afont%2Dsize%3A%2016px%3B%0A%7D%0Ah5%20%7B%0Afont%2Dsize%3A%2014px%3B%0A%7D%0Ah6%20%7B%0Acolor%3A%20%23777%3B%0Afont%2Dsize%3A%2014px%3B%0A%7D%0Abody%3Eh2%3Afirst%2Dchild%2C%20body%3Eh1%3Afirst%2Dchild%2C%20body%3Eh1%3Afirst%2Dchild%2Bh2%2C%20body%3Eh3%3Afirst%2Dchild%2C%20body%3Eh4%3Afirst%2Dchild%2C%20body%3Eh5%3Afirst%2Dchild%2C%20body%3Eh6%3Afirst%2Dchild%20%7B%0Amargin%2Dtop%3A%200%3B%0Apadding%2Dtop%3A%200%3B%0A%7D%0Aa%3Afirst%2Dchild%20h1%2C%20a%3Afirst%2Dchild%20h2%2C%20a%3Afirst%2Dchild%20h3%2C%20a%3Afirst%2Dchild%20h4%2C%20a%3Afirst%2Dchild%20h5%2C%20a%3Afirst%2Dchild%20h6%20%7B%0Amargin%2Dtop%3A%200%3B%0Apadding%2Dtop%3A%200%3B%0A%7D%0Ah1%2Bp%2C%20h2%2Bp%2C%20h3%2Bp%2C%20h4%2Bp%2C%20h5%2Bp%2C%20h6%2Bp%20%7B%0Amargin%2Dtop%3A%2010px%3B%0A%7D%0A%0Aa%20%7B%0Acolor%3A%20%234183C4%3B%0Atext%2Ddecoration%3A%20none%3B%0A%7D%0Aa%3Ahover%20%7B%0Atext%2Ddecoration%3A%20underline%3B%0A%7D%0A%0Aul%20%7B%0Apadding%2Dleft%3A%2014px%3B%0A%7D%0Aol%20%7B%0Apadding%2Dleft%3A%2022px%3B%0A%7D%0Aul%20li%20%3E%20%3Afirst%2Dchild%2C%20ol%20li%20%3E%20%3Afirst%2Dchild%2C%20ul%20li%20ul%3Afirst%2Dof%2Dtype%2C%20ol%20li%20ol%3Afirst%2Dof%2Dtype%2C%20ul%20li%20ol%3Afirst%2Dof%2Dtype%2C%20ol%20li%20ul%3Afirst%2Dof%2Dtype%20%7B%0Amargin%2Dtop%3A%200px%3B%0A%7D%0Aul%20ul%2C%20ul%20ol%2C%20ol%20ol%2C%20ol%20ul%20%7B%0Amargin%2Dbottom%3A%200%3B%0A%7D%0Adl%20%7B%0Apadding%3A%200%3B%0A%7D%0Adl%20dt%20%7B%0Afont%2Dsize%3A%2014px%3B%0Afont%2Dweight%3A%20bold%3B%0Afont%2Dstyle%3A%20italic%3B%0Apadding%3A%200%3B%0Amargin%3A%2015px%200%205px%3B%0A%7D%0Adl%20dt%3Afirst%2Dchild%20%7B%0Apadding%3A%200%3B%0A%7D%0Adl%20dt%3E%3Afirst%2Dchild%20%7B%0Amargin%2Dtop%3A%200px%3B%0A%7D%0Adl%20dt%3E%3Alast%2Dchild%20%7B%0Amargin%2Dbottom%3A%200px%3B%0A%7D%0Adl%20dd%20%7B%0Amargin%3A%200%200%2015px%3B%0Apadding%3A%200%2015px%3B%0A%7D%0Adl%20dd%3E%3Afirst%2Dchild%20%7B%0Amargin%2Dtop%3A%200px%3B%0A%7D%0Adl%20dd%3E%3Alast%2Dchild%20%7B%0Amargin%2Dbottom%3A%200px%3B%0A%7D%0A%0Apre%2C%20code%2C%20tt%20%7B%0Afont%2Dsize%3A%2013px%3B%0Afont%2Dfamily%3A%20Consolas%2C%20%22Liberation%20Mono%22%2C%20Courier%2C%20monospace%3B%0A%7D%0Acode%2C%20tt%20%7B%0Amargin%3A%200%200px%3B%0Apadding%3A%200px%200px%3B%0Awhite%2Dspace%3A%20nowrap%3B%0Aborder%3A%201px%20solid%20%23eaeaea%3B%0Abackground%2Dcolor%3A%20%23f8f8f8%3B%0Aborder%2Dradius%3A%203px%3B%0A%7D%0Apre%3Ecode%20%7B%0Amargin%3A%200%3B%0Apadding%3A%200%3B%0Awhite%2Dspace%3A%20pre%3B%0Aborder%3A%20none%3B%0Abackground%3A%20transparent%3B%0A%7D%0Apre%20%7B%0Abackground%2Dcolor%3A%20%23f8f8f8%3B%0Aborder%3A%201px%20solid%20%23ccc%3B%0Afont%2Dsize%3A%2013px%3B%0Aline%2Dheight%3A%2019px%3B%0Aoverflow%3A%20auto%3B%0Apadding%3A%206px%2010px%3B%0Aborder%2Dradius%3A%203px%3B%0A%7D%0Apre%20code%2C%20pre%20tt%20%7B%0Abackground%2Dcolor%3A%20transparent%3B%0Aborder%3A%20none%3B%0A%7D%0Akbd%20%7B%0A%2Dmoz%2Dborder%2Dbottom%2Dcolors%3A%20none%3B%0A%2Dmoz%2Dborder%2Dleft%2Dcolors%3A%20none%3B%0A%2Dmoz%2Dborder%2Dright%2Dcolors%3A%20none%3B%0A%2Dmoz%2Dborder%2Dtop%2Dcolors%3A%20none%3B%0Abackground%2Dcolor%3A%20%23DDDDDD%3B%0Abackground%2Dimage%3A%20linear%2Dgradient%28%23F1F1F1%2C%20%23DDDDDD%29%3B%0Abackground%2Drepeat%3A%20repeat%2Dx%3B%0Aborder%2Dcolor%3A%20%23DDDDDD%20%23CCCCCC%20%23CCCCCC%20%23DDDDDD%3B%0Aborder%2Dimage%3A%20none%3B%0Aborder%2Dradius%3A%202px%202px%202px%202px%3B%0Aborder%2Dstyle%3A%20solid%3B%0Aborder%2Dwidth%3A%201px%3B%0Afont%2Dfamily%3A%20%22Helvetica%20Neue%22%2CHelvetica%2CArial%2Csans%2Dserif%3B%0Aline%2Dheight%3A%2010px%3B%0Apadding%3A%201px%204px%3B%0A%7D%0A%0Ablockquote%20%7B%0Aborder%2Dleft%3A%204px%20solid%20%23DDD%3B%0Apadding%3A%200%2015px%3B%0Acolor%3A%20%23777%3B%0A%7D%0Ablockquote%3E%3Afirst%2Dchild%20%7B%0Amargin%2Dtop%3A%200px%3B%0A%7D%0Ablockquote%3E%3Alast%2Dchild%20%7B%0Amargin%2Dbottom%3A%200px%3B%0A%7D%0A%0Ahr%20%7B%0Aclear%3A%20both%3B%0Amargin%3A%200%200%3B%0Aheight%3A%200px%3B%0Aoverflow%3A%20hidden%3B%0Aborder%3A%20none%3B%0Abackground%3A%20transparent%3B%0Aborder%2Dbottom%3A%204px%20solid%20%23ddd%3B%0Apadding%3A%200%3B%0A%7D%0A%0Atable%20th%20%7B%0Afont%2Dweight%3A%20bold%3B%0A%7D%0Atable%20th%2C%20table%20td%20%7B%0Apadding%3A%200px%200px%3B%0A%7D%0Atable%20tr%20%7B%0A%7D%0A%0Aimg%20%7B%0Amax%2Dwidth%3A%20100%25%3B%0A%7D%0A%0A%2Etitle%20%7B%0Afont%2Dfamily%3A%20Variable%20Bold%2C%20Calibri%3B%0Afont%2Dsize%3A%2021pt%3B%0Atext%2Dalign%3A%20left%3B%0Aline%2Dheight%3A%201%3B%0Afont%2Dweight%3A%20bold%3B%0A%7D%0A%2EsubTitle%20%7B%0Afont%2Dfamily%3A%20Variable%20Bold%2C%20Calibri%3B%0Afont%2Dsize%3A%2019pt%3B%0Aline%2Dheight%3A%201%3B%0Acolor%3A%20rgb%28167%2C%2021%2C%200%29%3B%0Atext%2Dalign%3A%20left%3B%0Afont%2Dweight%3A%20bold%3B%0Adisplay%3A%20inline%3B%0A%7D%0A%2Eauthor%0A%7B%0Atext%2Dalign%3A%20center%3B%0Afont%2Dsize%3A%2016pt%3B%0Afont%2Dweight%3A%20bold%3B%0A%7D%0A%2Esidebar%0A%7B%0Abackground%2Dcolor%3A%20rgb%28167%2C%2021%2C%200%29%3B%0Acolor%3A%20white%3B%0Aline%2Dheight%3A%201%3B%0Apadding%2Dleft%3A%208px%3B%0Apadding%2Dtop%3A%208px%3B%0Apadding%2Dbottom%3A%208px%3B%0Amargin%2Dright%3A%208px%3B%0Amargin%2Dbottom%3A%208px%3B%0A%7D%0A%2Esidebar%20strong%0A%7B%0Abackground%2Dcolor%3A%20rgb%28167%2C%2021%2C%200%29%3B%0Acolor%3A%20white%3B%0A%7D%0A%2Esidebar%20code%0A%7B%0Abackground%2Dcolor%3A%20rgb%28167%2C%2021%2C%200%29%3B%0Aborder%3A%200%3B%0Acolor%3A%20white%3B%0A%7D%0A%2Ecolumn%0A%7B%0Awidth%3A%2033%25%3B%0Avertical%2Dalign%3A%20top%3B%0A%7D%0A%2Efooter%0A%7B%0Acolor%3A%20rgb%28167%2C%2021%2C%200%29%3B%0Aline%2Dheight%3A%201%3B%0A%7D%0A%2Efooter%20a%0A%7B%0Acolor%3A%20rgb%28167%2C%2021%2C%200%29%3B%20%7D%0Aimg%5Bsrc%2A%3D%22logo%2Epng%22%5D%0A%7B%0Aheight%3A%2080px%3B%0A%7D%0Atd%20strong%20%7B%0Acolor%3A%20rgb%28167%2C%2021%2C%200%29%3B%0Adisplay%3A%20inline%2Dblock%3B%0A%7D%0Aimg%5Balt%3D%22logo%22%5D%0A%7B%0Awidth%3A%2030%25%3B%0A%7D%0A" type="text/css" rel="stylesheet" /></p>
<table width="100%">
<tr>
<td class="title">
Coding Guidelines for C# 3.0, 4.0 and 5.0 Cheat Sheet
</td>
<td rowspan="2" style="text-align:right">
<img src="" alt="logo" />
</td>
</tr>
<tr>
<td>
<div class="subTitle">
Design &amp; Maintainability
</div>
(level 1 and 2 only)
</td>
</tr>
</table>
<table width="100%">
<tr>
<td class="column">
<div class="sidebar" markdown="1">
<p><strong>基本原则</strong></p>
<ul>
<li>The Principle of Least Surprise最小惊奇原则<br />
</li>
<li>Keep It Simple Stupid保持简单<br />
</li>
<li>You Ain’t Gonne Need It你是不是以后才需要它<br />
</li>
<li>Don’t Repeat Yourself减少重复</li>
</ul>
</div>
<p><strong>Class Design(类设计)</strong></p>
<ul>
<li>一个类或接口应该只有一个目的 (AV1000)</li>
<li>一个接口应该小和集中 (AV1003)<br />
</li>
<li>使用接口将类彼此解耦 (AV1005)<br />
</li>
<li>不要用<code>new</code>关键字隐藏继承成员 (AV1010)<br />
</li>
<li>应该将派生对象视为基类对象 (AV1011)<br />
</li>
<li>不要从基类引用派生类 (AV1013)<br />
</li>
<li>避免暴露对象依赖的对象(AV1014)<br />
</li>
<li>避免双向依赖 (AV1020)<br />
</li>
<li>类应该有状态和行为 (AV1025)</li>
</ul>
<p><br /> <strong>Member Design(成员设计)</strong></p>
<ul>
<li>允许按任意顺序设置属性 (AV1100)<br />
</li>
<li>不要使用互斥属性 (AV1110)<br />
</li>
<li>方法或属性应该只做一件事 (AV1115)<br />
</li>
<li>不要通过静态成员公开状态对象 (AV1125)<br />
</li>
<li>返回一个<code>IEnumerable&lt;T&gt;</code> 或 <code>ICollection&lt;T&gt;</code> 代替具体的集合类 (AV1130)<br />
</li>
<li>表示字符串或集合的属性、方法和参数不应该是<code>null</code> (AV1135)<br />
</li>
<li>尽可能具体地定义参数 (AV1137)<br />
</li>
</ul>
</td>
<td class="column">
<p><strong>Miscellaneous Design(杂项设计)</strong></p>
<ul>
<li>抛出异常而不是返回状态值 (AV1200)<br />
</li>
<li>提供一个丰富而有意义的异常消息文本 (AV1202)<br />
</li>
<li>不要通过捕获一般异常来掩盖错误 (AV1210)<br />
</li>
<li>总是检查事件处理程序委托是否为<code>null</code> (AV1220)<br />
</li>
<li>正确处理异步代码中的异常 (AV1215)<br />
</li>
<li>使用受保护的虚拟方法来引发每个事件 (AV1225)<br />
</li>
<li>在引发事件时，不要将<code>null</code>作为发送方参数传递。 (AV1235)<br />
</li>
<li>如果适用，使用泛型约束 (AV1240)<br />
</li>
<li>在返回LINQ结果前应先对该LINQ表达式求值 (AV1250)</li>
</ul>
<p><br /> <strong>Maintainability(可维护性)</strong></p>
<ul>
<li>方法不应超过7个语句 (AV1500)<br />
</li>
<li>使所有成员都为<code>private</code>，并默认为<code>internal</code>类型 (AV1501)<br />
</li>
<li>避免双重否定的条件 (AV1502)<br />
</li>
<li>不要用 &quot;magic numbers(魔法数字)&quot; (AV1515)<br />
</li>
<li>只有当类型非常明显时才使用<code>var</code> (AV1520)<br />
</li>
<li>尽可能晚地声明和初始化变量 (AV1521)<br />
</li>
<li>在使用Object和Collection使用初始化器时尽量写在单独的语句中 (AV1523)<br />
</li>
<li>不要对 <code>true</code> 或 <code>false</code>进行显式的比较 (AV1525)<br />
</li>
<li>不要在 <code>for</code> 或 <code>foreach</code> 循环中改变循环变量 (AV1530)<br />
</li>
<li>避免嵌套循环 (AV1532)<br />
</li>
</ul>
</td>
<td class="column">
<ul>
<li>在 <code>if</code>, <code>else</code>, <code>while</code>, <code>for</code>, <code>foreach</code> and <code>case</code>后总是添加一个块 (AV1535)<br />
</li>
<li>在<code>switch</code>的最后一个<code>case</code>后，总是添加一个<code>default</code>块 (AV1536)<br />
</li>
<li>每个 <code>if</code>-<code>else</code>-<code>if</code>声明后都应该用<code>else</code>-部分，来使整个语句更完整 (AV1537)<br />
</li>
<li>要厌恶使用多个<code>return</code>语句 (AV1540)<br />
</li>
<li>不要用 <code>if</code>-<code>else</code> 语句代替简单的（条件）赋值。 (AV1545)<br />
</li>
<li>在方法或属性中封装复杂表达式 (AV1547)<br />
</li>
<li>Call the most overloaded method from other overloads (AV1551)<br />
</li>
<li>只使用可选参数替换重载。 (AV1553)<br />
</li>
<li>避免使用命名参数 (AV1555)<br />
</li>
<li>不允许超过三个参数的方法和构造函数 (AV1561)<br />
</li>
<li>不要用 <code>ref</code> 或 <code>out</code> 参数 (AV1562)<br />
</li>
<li>避免方法带一个 <code>bool</code> 标志 (AV1564)<br />
</li>
<li>对于带<code>as</code>的运算一定要检查其结果 (AV1570)<br />
</li>
<li>不要注释代码(用版本管理工具) (AV1575)</li>
</ul>
<p><br /> <strong>Framework Guidelines(框架指南)</strong></p>
<ul>
<li>用C #类型别名代替 <code>System</code> 命名空间的类型 (AV2201)<br />
</li>
<li>以最高警告级别构建 (AV2210)<br />
</li>
<li>使用lambda表达式代替委托 (AV2221)<br />
</li>
<li>仅在与动态对象交互时使用<code>dynamic</code>关键字 (AV2230)<br />
</li>
<li>相对于 <code>Task</code> 优先使用<code>async</code>/<code>await</code> (AV2235)<br />
</li>
</ul>
</td>
<tr>
<table width="100%" class="footer">
<tr>
<td>
Dennis Doomen<br />
Version 5.0.0 (October 18, 2016)
</td>
<td style="text-align:right">
<a href="http://www.csharpcodingguidelines.com">www.csharpcodingguidelines.com</a><br />
<a href="www.continuousimprover.com" class="uri">www.continuousimprover.com</a><br />
<a href="http://www.avivasolutions.nl">www.avivasolutions.nl</a>
</td>
</tr>
</table>
<table width="100%" style="page-break-before: always;">
<tr>
<td class="title">
Coding Guidelines for C# 3.0, 4.0 and 5.0 Cheat Sheet
</td>
<td rowspan="2" style="text-align:right">
<img src="" alt="logo" />
</td>
</tr>
<tr>
<td>
<div class="subTitle">
Naming &amp; Layout(命名和布局)
</div>
(level 1 and 2 only)
</td>
</tr>
</table>
<table width="100%">
<tr>
<td class="column">
<div class="sidebar">
<table>
<thead>
<tr class="header">
<th align="left"><strong>Pascal Casing</strong></th>
<th></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">Class, Struct</td>
<td><code>AppDomain</code></td>
</tr>
<tr class="even">
<td align="left">Interface</td>
<td><code>IBusinessService</code></td>
</tr>
<tr class="odd">
<td align="left">Enumeration type</td>
<td><code>ErrorLevel</code></td>
</tr>
<tr class="even">
<td align="left">Enumeratiion values</td>
<td><code>FatalError</code></td>
</tr>
<tr class="odd">
<td align="left">Event</td>
<td><code>Click</code></td>
</tr>
<tr class="even">
<td align="left">Protected field</td>
<td><code>MainPanel</code></td>
</tr>
<tr class="odd">
<td align="left">Const field</td>
<td><code>MaximumItems</code></td>
</tr>
<tr class="even">
<td align="left">Read-only static field  </td>
<td><code>RedValue</code></td>
</tr>
<tr class="odd">
<td align="left">Method</td>
<td><code>ToString</code></td>
</tr>
<tr class="even">
<td align="left">Namespace</td>
<td><code>System.Drawing</code></td>
</tr>
<tr class="odd">
<td align="left">Property</td>
<td><code>BackColor</code></td>
</tr>
<tr class="even">
<td align="left">Type Parameter</td>
<td><code>TEntity</code></td>
</tr>
<tr class="odd">
<td align="left"></td>
<td></td>
</tr>
<tr class="even">
<td align="left"><br /><strong>Camel Casing</strong></td>
<td></td>
</tr>
<tr class="odd">
<td align="left">Private field</td>
<td><code>listItem</code></td>
</tr>
<tr class="even">
<td align="left">Variable</td>
<td><code>listOfValues</code></td>
</tr>
<tr class="odd">
<td align="left">Const variable</td>
<td><code>maximumItems</code></td>
</tr>
<tr class="even">
<td align="left">Parameter</td>
<td><code>typeName</code></td>
</tr>
</tbody>
</table>
</div>
<p><br /> <strong>Naming(命名)</strong></p>
<ul>
<li>Use US English (AV1701)</li>
<li>不要在变量、参数和类型成员中使用数字 (AV1704)</li>
<li>不要给字段加前缀 (AV1705)</li>
<li>不要使用缩写 (AV1706)</li>
<li>命名成员、参数或变量应根据其含义而不是其类型 (AV1707)</li>
<li>命名类型应使用名词、名词短语或形容词短语 (AV1708)</li>
<li>不要在类或枚举的成员中重复其(类或枚举)名称 (AV1710)</li>
<li>避免与其他名字相混淆的短名称或名称 (AV1712)</li>
<li>方法的命名使用“动词-对象”组合 (AV1720)</li>
<li>对命名空间命名时，使用名称、层、动词和功能 (AV1725)</li>
</ul>
</td>
<td class="column">
<ul>
<li>用下划线表示不相关的lambda参数 (AV1739)</li>
</ul>
<p><strong>Documentation(文档、注释)</strong></p>
<ul>
<li>Write comments and documentation in US English (AV2301)</li>
<li>对所有的public, protected 和 internal 类型和成员写注释 (AV2305)</li>
<li>避免(方法)内嵌注释 (AV2310)</li>
<li>只对复杂的算法或决策写注释 (AV2316)</li>
<li>不要使用注释来跟踪稍后要做的工作。 (AV2318) <br /></li>
</ul>
<p><strong>Layout(布局)</strong></p>
<ul>
<li>最大行长度为130个字符。</li>
<li>缩进4个空格, 不要用 Tabs</li>
<li>在关键词及其表达式之间保持一个空格，例如 <code>if</code> , 但是不要在 <code>(</code>后和 <code>)</code>前加空格。</li>
<li>在运算符两边加空格，例如 <code>+</code>, <code>-</code>, <code>==</code>, 和其他。</li>
<li>总是在关键字<code>if</code>, <code>else</code>, <code>do</code>, <code>while</code>, <code>for</code> and <code>foreach</code>之后添加圆括号。</li>
<li>总是把开始和结束括号放在新行上。</li>
<li>不要缩进对象初始器，并且每行初始化一个属性。</li>
<li>不要缩进lambda表达式</li>
<li>把整个LINQ语句在同一行，或者每个关键字在同一缩进位置。</li>
<li>在比较条件两边添加括号，但不要在单个条件时添加括号。</li>
</ul>
</td>
<td class="column">
<div class="sidebar" markdown="1">
<p><strong>Empty lines(空行)</strong></p>
<ul>
<li>成员之间</li>
<li>在结束括号之后</li>
<li>多行语句之间</li>
<li>不相关代码块之间</li>
<li>在 <code>#region</code> 两侧</li>
<li>在不同根命名空间的<code>using</code>语句之间</li>
</ul>
</div>
<div class="sidebar">
<p><strong>Member order(成员顺序)</strong></p>
<ol style="list-style-type: decimal">
<li>私有字段和常量</li>
<li>公共常量</li>
<li>公共只读静态字段</li>
<li>工厂方法</li>
<li>构造函数和析构函数</li>
<li>事件</li>
<li>公共属性</li>
<li>调用顺序中的其他方法和私有属性</li>
</ol>
</div>
<div class="sidebar" markdown="1">
<p><strong>Important Note</strong></p>
<p>These coding guidelines are an extension to Visual Studio's Code Analysis functionalty, so make sure you enable that for all your projects. Check the full document for more details.</p>
</div>
<td></td>
<tr>
<table width="100%" class="footer">
<tr>
<td>
Dennis Doomen<br />
Version 5.0.0 (October 18, 2016)<br />

</td>
<td style="text-align:right">
<a href="http://www.csharpcodingguidelines.com">www.csharpcodingguidelines.com</a><br />
<a href="www.continuousimprover.com" class="uri">www.continuousimprover.com</a><br />
<a href="http://www.avivasolutions.nl">www.avivasolutions.nl</a><br />

</td>
</tr>
</table>
</body>
</html>
